﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tblImagesDAL : SqlDataProvider
	{

		#region[tblImages_GetbyAll]
		public DataTable tblImages_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tblImages_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblImages_GetbyId]
		public DataTable tblImages_GetById(tblImagesInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblImages_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_imgid", Data._imgid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblImages_GetbyTop]
		public DataTable tblImages_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tblImages_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblImages_Getby_iaid]
		public DataTable tblImages_GetBy_iaid(string _iaid)
		{
			using (var cmd = new SqlCommand("sp_tblImages_GetBy_iaid", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_iaid", _iaid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblImages_Insert]
		public void tblImages_Insert(tblImagesInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblImages_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_iaid", Data._iaid));
				cmd.Parameters.Add(new SqlParameter("@_imgname", Data._imgname));
				cmd.Parameters.Add(new SqlParameter("@_imglink", Data._imglink));
				cmd.Parameters.Add(new SqlParameter("@_imgcreatedate", Data._imgcreatedate));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblImages_Update]
		public void tblImages_Update(tblImagesInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblImages_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_iaid", Data._iaid));
				cmd.Parameters.Add(new SqlParameter("@_imgid", Data._imgid));
				cmd.Parameters.Add(new SqlParameter("@_imgname", Data._imgname));
				cmd.Parameters.Add(new SqlParameter("@_imglink", Data._imglink));
				cmd.Parameters.Add(new SqlParameter("@_imgcreatedate", Data._imgcreatedate));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblImages_Delete]
		public void tblImages_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tblImages_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_imgid", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}